Repository navigation
fix!: limit ids and names, and require a plain since - #64
Merged
Merged
Conversation
`since` was read with Number(), so "1e400" became Infinity and was answered uptodate at the current position without sending anything, and "abc" became NaN and got a snapshot. The frame guard now requires `since` to be a plain decimal of at most 19 digits (SQLite's largest INTEGER) and drops any other frame per ADR-0012 D1. A well formed since past the current position gets reset and a snapshot instead of uptodate. BREAKING CHANGE: a raw client that spells `since` any other way gets no reply for that sub. The library's client always sends the plain decimal form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…heir own reply A sub id was bounded only by the frame size, yet it is echoed in every frame of its sub and stored in _sync_subs; a txId is stored in _sync_seen_tx; an unknown collection or command name was quoted in a stored rejection. An id (subId, fetchId, txId) may be at most 256 UTF-8 bytes and a collection or command name at most 128. A frame over a limit gets its frame type's own refusal, echoing the id once, with nothing stored: reset for a sub, an empty page for a fetch, rejected LIMIT_EXCEEDED for a mut or call (before the dedup lookup and not recorded), and an unsub is ignored. compileSchema refuses a table or command name over 128 bytes, so every id the library's client builds stays under the limit. The two backstop tests that reached the _sync_subs row cap with a 600 KB sub id now reach it with a predicate just under the cap. BREAKING CHANGE: a raw client whose ids are over 256 bytes, or names over 128, is refused; an app supplied transaction id over 256 bytes is rejected with LIMIT_EXCEEDED; a schema with a table or command name over 128 bytes fails to register. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ast the head
The server now drops a since that is not plain decimal digits. parseSyncMeta
accepted any cursor BigInt parses (" 5", "05", "0x5") and the eager and
on-demand hydration paths sent it on unchanged, so changed meta would leave a
collection that silently stops receiving updates. parseSyncMeta now returns
the plain form and refuses a cursor past the largest the server accepts, like
an unparseable one; seedCursor refuses that cursor too.
The ADR-0012 amendment now states the reset for a since past the head as its
own decision, with what each kind of subscription does on it, pinned through
the real client for the eager sub and the hydration catch-up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ce at subscribe The txId length check now runs in #oncePerTx, after the dedup lookup and before the txId is reserved, so ADR-0025's rule holds without exception: a receipt stored under a long txId before the limit still replays, and a refused txId is neither recorded nor left in flight. Transport.subscribe refuses a since that is not a position in plain decimal form, at the call, instead of sending a sub the server drops with no reply. The pattern now lives in src/wire/frames.ts for both ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and an exact row cap The id limit answered first for the tests that pinned the clip of the fetch predicate refusal, the compiler's sub refusal and the malformed cursor, and nothing pinned the txId refusal's clip. Each now has a test that asserts the id's own clipped form, and fails when that one clip is removed. L3 pins, as it.fails, that a reset for a since above the head does not repair the cursor (ADR-0011 "No incarnation epoch"). The row cap helper imports MAX_VALUE_BYTES and pads the stored form to exactly one byte under it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he id and name limits Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merges the frame guard change: ids at most 256 bytes and names at most 128, refused with a reply; a since that is not a plain decimal position is a malformed frame; a since above the head gets reset and a snapshot; the client sends a hydrated cursor in its plain form. Adds the changelog entries and two sentences the review asked for in ADR-0012. BREAKING CHANGE: a table or command name over 128 bytes fails registerSync, and an id over 256 bytes is refused. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two gaps in the server's frame guard, both found by reviewers of earlier work.
sincewas parsed loosely.since: "1e400"became Infinity and the server answereduptodatewithout sending anything.since: "abc"got a snapshot.What changed
resetfor a sub, an emptypagefor a fetch,rejectedwithLIMIT_EXCEEDEDfor a mutation or command. Anunsubover the limit is ignored. The check for a transaction id runs after the dedup lookup, so a receipt stored under a longer id before this release still replays (ADR-0025's rule holds with no exception).registerSync. That keeps every id the library's own client builds at 158 bytes or less.sincemust be a plain decimal position: digits only, no sign, no leading zero, at most 19 digits. Anything else makes the frame malformed, and it is dropped with a log line.Transport.subscriberefuses such asinceat the call, so a raw caller gets an error instead of waiting for ever.sinceabove the head of the change log getsresetand a snapshot, where it gotuptodate. A client of an object whose storage was recreated kept the old rows for ever."05", still resumes.Breaking changes
registerSyncthrows.createTransaction({ id }): the write is rejected withLIMIT_EXCEEDED.sincethat is not in the plain form.A limit this does not close
After the
resetfor asinceabove the head, the client has the right rows on that connection, but its cursor still sits above the head. Each reconnect snapshots again until the object passes the cursor. If the object passes it while the client is away, the rows written in between are missed. This is the known limitation "No incarnation epoch" of ADR-0011. It is stated in the ADR and the changelog and pinned by a test written as an expected failure, so closing it later will flag itself.Verification
@tanstack/db1.0.0-rc.1.5 and 0.8.6.Not verified by a run: an on-demand watch that meets the
reseton a reconnect (read from the code), and a transaction id over SQLite's value cap of 2 200 000 bytes when a subclass has raisedmaxFrameBytesabove it (it gets no reply, as before).The decisions are a dated amendment to ADR-0012.
🤖 Generated with Claude Code